package ru.alt22.visor.php.ui.utils;

import java.util.ArrayList;

public class CompositeAcceptable implements Acceptable {
	private ArrayList<Acceptable> items;
	private boolean accept;

	public CompositeAcceptable() {
		items = new ArrayList<Acceptable>();
		setDefault(true);
	}

	public void add(Acceptable acceptable) {
		items.add(acceptable);
	}

	public void setDefault(boolean accept) {
		this.accept = accept;
	}

	public boolean accept(Object element) {
		for (int i = 0; i < items.size(); i++) {
			if (!items.get(i).accept(element)) {
				return false;
			}
		}
		return accept;
	}

}
